/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.marifnst.itd.util;

import javax.swing.table.DefaultTableModel;

/**
 *
 * @author marifnst
 */
public class UtilTable {

    private static UtilTable utilTable;

    public static UtilTable getInstance() {
        if (utilTable == null) {
            utilTable = new UtilTable();
        }
        return utilTable;
    }

    public void generateDataTable(DefaultTableModel tableModel, String key) {
//        String queryFormat = "SELECT name, mean FROM data_%c where name like '%s%'";
        String query = String.format("SELECT * FROM data_%s where name like '%s'",
                key.toLowerCase(),
                key.toLowerCase() + "%");
        String[][] data = UtilDatabase.getInstance().executeQuery(key.toLowerCase().charAt(0), query);
        for (String[] s : data) {
            tableModel.addRow(s);
        }
    }
}
